package com.jp.knowledge.activity;

import android.content.Context;
import android.content.Intent;
import com.jp.knowledge.R;
import com.jp.knowledge.comm.SlidingActivity;
import com.jp.knowledge.view.JpWebView;
import com.tencent.smtt.sdk.WebSettings;

import org.xutils.view.annotation.ViewInject;

/**
 * Created by 528787067@qq.com on 2017/1/15.
 */

public class LoadingWebActivity extends SlidingActivity {

    @ViewInject(R.id.jpWebView)
    protected JpWebView jpWebView;

    public static void openWebActivity(Context context, String url){
        context.startActivity(new Intent(context, LoadingWebActivity.class)
                .putExtra("loadingUrl", url));
    }

    @Override
    protected int getResourceId() {
        return R.layout.activity_web_main;
    }

    @Override
    protected void init() {
//        jpWebView.getWebSettings().setSupportZoom(true);

        WebSettings settings =  jpWebView.getWebSettings();
        settings.setJavaScriptEnabled(true);

        //支持屏幕缩放
        settings.setSupportZoom(true);
        settings.setBuiltInZoomControls(true);
        //不显示webview缩放按钮
        settings.setDisplayZoomControls(false);

        jpWebView.loadUrl(getIntent().getStringExtra("loadingUrl"));
    }

    @Override
    protected void onDestroy() {
        jpWebView.destory();
        super.onDestroy();
    }

    @Override
    public void onBackPressed() {
        if (!jpWebView.goBack())
            finish();
    }
}
